package com.kdd.campus.sh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kdd.campus.sh.dao.ShAdMapper;
import com.kdd.campus.sh.po.ShAd;
import com.kdd.campus.sh.service.AdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Auther: fcp
 * @Date: 2020/2/22 22:47
 * @Description:
 */
@Service
public class AdServiceImpl implements AdService {

    @Autowired
    private ShAdMapper adMapper;

    @Override
    public List<ShAd> findAdList(int location) {
        PageHelper.startPage(0,4);
        Example example = new Example(ShAd.class);
        example.setOrderByClause("created DESC");
        example.createCriteria()
                .andEqualTo("location", location)
                .andEqualTo("status", 1);

        return adMapper.selectByExample(example);
    }
}
